<?
$sg_f = $user_profile->get_bookmark_folders();       
if ($nav_folder!="")
{ # set selected folder
    #$cookie_bookmark = $profile [$nav_folder];

	
	$bookmark_count = 0;
	$preview  = false;
	$arr      = $user_profile->get_bookmark_folder($nav_folder);
	$cnt      = count($arr);
	$row_data = "<tr>";
	
	// draw bookmark list
	for ($e=0;$e<count ($arr);$e++)
	{ 
		$art = $arr[$e];
		if (strlen($art)>0)
		{
		   $bookmark_count++;
			$mark = explode (",", $art);
			 
			 
			 $caption=preg_replace (
						  array("/alt\./","/\.binaries/","/\.multimedia/","/\.pictures/","/\.nospam/","/\.erotic[a]*/","/\.nonude/"),
						  array("a.",".b",".m",".p",".ns",".e",".nn"),
						   $mark[0]
						 );
						 
						  
			 $caption = chop_str($caption, 25);
			  if ($preview==false)
				 {
					 $preview = $art;
				 }                                           
			 $subject     = base64_decode($mark[2]);   
			 $subcaption  = chop_str(stripslashes($subject), 25);
			 $src         = $href . "?message_id=" . $mark[1] . "&art_group=" . $mark[0] . "&pp_w=96&center=true&shadow=true";
			 $media_test  = preg_match(REGEX_MASK_MEDIA, $subject, $media_map);   
			 $flag        = "false";  
			 if ($media_test)
			 {
			     $src = "images/nntp_movie_icon_x96.gif";
			     $flag = "true";
			 }
			 # if it exists, create a preview square
			 $row_data .= " 
				<td valign=top style='' align=center>
					<div style='border:solid 1px silver;width:96px;height:96px;overflow:hidden' id='p" . $mark[1] . "'>
						<a href=\"javascript:load_image('" . $mark[1] . "','" . $mark[0] . "', $flag)\">
						<img border='0' onload='desktop_background_resize()' 
						onerror=\"MM_findObj('p" . $mark[1] . "').innerHTML='Preview not available<br>';\" 
						src='" . $src . "'></a>  
					</div>
					<a href='" . $href . "?a=dbook&k=" . $art . "&bkdir=" . $nav_folder . "' target=_blank
					><font style='font-family:webdings' face='webdings'>r</font></a>
					<a href='" . $href . "?g=" . $mark[0] . "'>" . $caption . "</a> <br> 
					<a href=\"javascript:load_image('" . $mark[1] . "','" . $mark[0] . "', $flag)\">$subcaption</a> 
				</td>
				";   
			 
			 
			if ($bookmark_count%5==0)
			{
			     $row_data .= "</tr><tr>";
			}
			
			 
		}
	}
	

} 

$mark = explode (",", $preview);
$src  = "".$href."?message_id=".$mark[1]."&art_group=".$mark[0]."&pp_w=240";



// preview cell
print "<table><tr><td width=180 valign=top bgcolor='white'
    ><div style='background-color:white;margin:2px'
			class='resizeY'>
  <div id='dpreview' align=center
		style='width:240;
			 height:240;
			 display:none;
			 border:solid 1px silver;
			 overflow:hidden;
			 filter: progid:DXImageTransform.Microsoft.RandomDissolve();'>
		   <img id='ipreview' 
				border='0'  
				onerror='image_fail()'
				src='" . $src . "'
						  >
			 </div>
			 
			 <div id='dserver'>";
			 
if ($preview)
{		 
	  print "<"."script>infobomb ('". $mark[1] ."', '". $mark[0] ."')<"."/script>";
}
else if ($nav_folder=="")
{ # bookmark folders treeview
	# parse_str ($cookie_folders);
	print "<div style='padding:3px'>
	          <img src='image.php?i=x' height='1' width='180'><br>
			  <table cellpadding=0 cellspacing=0><tr><td colspan=2><img align='absmiddle' src='image.php?i=book'>
				Folders</td></tr>";
				
				
				
	$row_data="";
	for ($e=0;$e<count($sg_f);$e++) 
	{
	
		$folder = $sg_f[$e];
		$icon   = $e==count($sg_f)-1?"b_sub.gif":"sub.gif";
		
		print "<tr><td><img src='images/" . $icon . "'></td><td>
			   <a href=\"javascript:fb_edit('bkf','" . $folder . "')\">" . $folder . "</a></td></tr>";
	
		$arr  = $user_profile->get_bookmark_folder($folder);
		# print_r ($arr);
		$dot = 0;
		$art = "";
		while ($art==""&&$dot<count($arr))
		{
		    $art  = $arr[$dot];
			$dot ++;
		}
		#echo $art;
		
		$mark = explode (",", $art); 
		$row_data .= "<td align=center ";
		
		if (count ($arr) > 0 && strlen($art) > 0)
		{
			$row_data .= "><div style='width:96;height:96;overflow:hidden;border:solid 1px silver' id='p".$mark[1]."'>
				<a href=\"javascript:fb_edit('bkf','".$folder."')\">
				<img border='0' onload='desktop_background_resize()' 
				onerror=\"MM_findObj('p".$mark[1]."').innerHTML='Preview not available<br>'+this.src\" 
				src='".$href."?message_id=".$mark[1]."&art_group=".$mark[0]."&pp_w=96'></a>  
				</div>";
		}
		else
		{
		    $row_data .= "valign='bottom'><a href=\"javascript:fb_edit('bkf','" . $folder . "')\"
			              >&lt;empty&gt;</a>";
		}
	
		$row_data .= "<br><a href=\"javascript:fb_edit('bkf','".$folder."')\"
				>" . $folder . " (" . count ($arr) . ")<font color='#666666' face='Times New Roman, Times, serif' size='3'
		        ></font></a></td>";
				
		if (($e+1)%5==0)
		{
			$row_data .= "</tr><tr>";
		}
	}
	print "</table></div>";
}
print " </div> </div> </td>

<td valign='top'> 

<!-- toolbar -->";


if (count($sg_f) > 0)
{ # folder navigation dropdown 
	print "Folders: <select onchange=\"fb_edit('bkf', this.value)\" id='sltbkfolder'>
	                <option value=''>Choose"; 
	foreach ($sg_f as $folder)
	{
	    if ($folder==$nav_folder)
		{
	        print "<option value='" . $folder . "' selected>" . $folder;
		}
		else
		{
	        print "<option value='" . $folder . "'>" . $folder;
		}
	}
	print "</select>";
}
print "&nbsp;<input type=button onclick='javascript:add_bookmark_dir()' value='New Folder'>&nbsp;"; 
print $bookmark_count . " bookmarked images. <br>";


print " 
<!-- workspace -->

<div style='background-color:white;margin:2px' class='resizeXY'
 ><table cellspacing='4' cellpadding='2'>" . $row_data . "</table>";
 
 
print " </div>
	    </td> 
	</tr>
</table>";

?>



 <script language="javascript">
 desktop_background_resize();
 </script>